﻿namespace Nomo.UnityEditorModule
{
    [UnityEditor.CustomPropertyDrawer(typeof(UnityCoreModule.ReadonlyAttribute))]
    internal sealed class ReadonlyDrawer : UnityEditor.PropertyDrawer
    {
        public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            return UnityEditor.EditorGUI.GetPropertyHeight(property, label, true);
        }

        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var guiEnabled = UnityEngine.GUI.enabled;
            UnityEngine.GUI.enabled = false;
            UnityEditor.EditorGUI.PropertyField(position, property, label, true);
            UnityEngine.GUI.enabled = guiEnabled;
        }
    }
}
